#ifndef _CXYZCHART_H_
#define _CXYZCHART_H_

#include <buola/chart/cchart.h>

#include <buola/chart/clegend.h>
#include <buola/chart/c3daxis.h>

#include <buola/utility/usignal.h>
#include <buola/image/ccolor.h>

namespace buola { namespace chart {

struct CXYZChartContext
{
    PXYZChart mChart;

    img::CGC *mGC;
    CRect_d mRect;

    C3DAxis *mXAxis;
    C3DAxis *mYAxis;
    C3DAxis *mZAxis;

    double mMinX;
    double mMaxX;
    double mMinY;
    double mMaxY;
    double mMinZ;
    double mMaxZ;
    double mMinPosX;
    double mMinPosY;
    double mMinPosZ;

    CLegend *mLegend;
};

//!base class for XYZ charts
class CXYZChart : public CChart
{
public:
    CXYZChart();
    ~CXYZChart();

    //!add a new plot
    void AddPlot(PXYZPlot pPlot);
    //!remove a previously added plot
    void RemovePlot(PXYZPlot pPlot);
    //!remove all plots
    void RemovePlots();

    //!returns a pointer to the X axis
    CAxis *GetXAxis()              {   return mXAxis;  }
    //!returns a pointer to the Y axis
    CAxis *GetYAxis()              {   return mYAxis;  }
    //!returns a pointer to the Z axis
    CAxis *GetZAxis()              {   return mZAxis;  }

    //!returns a reference to the list of plots
    const std::vector<PXYZPlot> &GetPlots() {   return mPlots;  }

    virtual void OnButtonDown(const gui::CMouseEvent &pE);
    virtual void OnMouseMove(const gui::CMouseEvent &pE);
    virtual void OnExpose(const gui::CExposeEvent &pE);

    PXYZPlot GetPlotAt(const CPoint_d &pPos);

public:
    //!signal
    USignal<void(PXYZPlot)> sPlotLocked;

private:
    std::vector<PXYZPlot> mPlots;

    PXYZPlot mTraceLock;

    C3DAxis *mXAxis;
    C3DAxis *mYAxis;
    C3DAxis *mZAxis;
    CLegend *mLegend;

    //! \name data for interaction
    //CRect_d mDataRect;

    double mXRot;
    double mZRot;

    CPoint_d mMousePos;
};

/*namespace chart*/ } /*namespace buola*/ }

#endif
